#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, m, q; cin >> n >> m >> q;
    vector<vector<int>> arr(n + 1, vector<int>(m + 1));
    auto prev = arr;
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j)
        cin >> arr[i][j];
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j)
        prev[i][j] = arr[i][j] + prev[i - 1][j] + prev[i][j - 1] - prev[i - 1][j - 1];
    while(q--)
    {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        cout << (prev[x2][y2] - prev[x2][y1 - 1] - prev[x1 - 1][y2] + prev[x1 - 1][y1 - 1]) << endl;
    }
    return 0;
}